


const myMap: Map<string, number> = new Map<string, number>();
myMap.set("test1", 1);
myMap.set("test2", 2);
myMap.set("test3", 3);
myMap.set("test4", 4);

myMap.forEach((value: number, key: string) => {
    console.log({ key, value });
});

myMap.forEach((value: number, key: string) => {
    value = -value;// 形参修改无意义
});

myMap.forEach((value: number, key: string) => {
    console.log({ key, value });
});

interface SocketStreamInfo {
    callId: string;
    isStart: Boolean;
}

const dataMap: Map<string, SocketStreamInfo> = new Map<string, SocketStreamInfo>(); //<socketId,SocketStreamInfo{callId,isStart}>

const socketId = "testSocketId";
const callId = "testCallId";

const info: SocketStreamInfo = { callId: callId, isStart: false };
dataMap.set(socketId, info);

console.log('caonima111');
dataMap.forEach((info: SocketStreamInfo, socketId: string) => {
    console.log({ socketId, info });
});

for (const value in dataMap) {
    console.log();
}
console.log('caonima222');

dataMap.forEach((info: SocketStreamInfo, socketId: string) => {
    info.isStart = true; // 测试证明，info为形参，改变其值对map中的数据无影响，但是修改info中的元素的修改，可改变map中的info中元素的值。
    const newInfo: SocketStreamInfo = { callId: "errorCallId", isStart: false };
    info = newInfo; // 形参修改无意义
});

dataMap.forEach((info: SocketStreamInfo, socketId: string) => {
    console.log({ socketId, info });
});

